<template>
  <page-view class="body">
    <div v-show="videoState" @click="hideVideo" class="movieVideo">
        <video ref="video" controls :src="detailMovieList.videourl"></video>
    </div>
    <m-header>
      <div class="iconfont icon-return back" @click="$router.back()" slot="back"></div>
      <div slot="body">{{detailMovieList.nm}}</div>
      <div class="iconfont icon-shoucang1 collect" slot="collect"></div>
      <div class="iconfont icon-fenxiang share" slot="share"></div>
    </m-header>
    <div class="content">
      <img v-lazy="detailMovieList.img" alt class="bgImg"/>
      <div class="left">
        <img v-lazy="detailMovieList.img" alt  @click="videoState=1" />
      </div>
      <ul class="center">
        <li class="nm">{{detailMovieList.nm}}</li>
        <li>
          <span class="sc">{{detailMovieList.sc}}</span>
          ({{detailMovieList.wish}}想看)
        </li>
        <li>{{detailMovieList.cat}}</li>
        <li>{{detailMovieList.dur}}分钟</li>
        <li>{{detailMovieList.pubDesc}}</li>
      </ul>
      <div class="right">
        <span class="iconfont icon-arrow-right"></span>
      </div>
    </div>
    <div class="By">
      <button type="button">我要购票</button>
    </div>
    <div class="dra" ref="dra" :class="[slideType==0?'active':0]">{{detailMovieList.dra}}</div>
    <div class="slideToggle">
      <span v-if="slideType" class="iconfont icon-changyongtubiao-xianxingdaochu-zhuanqu-"  @click="slideType=0"></span>
      <span v-else class="iconfont icon-shangjiantou" @click="slideType=1"></span>
    </div>
  </page-view>
</template>
<script>
import {mapActions} from "vuex"
import MHeader from "../components/MHeader.vue";
import { type } from 'os';
export default {
  name: "Detail",
  components: {
    MHeader
  },
  data() {
    return {
      detailMovieList: {},
      slideType:1,
      videoState:0,
    };
  },
  mounted() {
    this.getDetail();
  },
  methods: {
    ...mapActions(["showLoading","hideLoading"]),
    async getDetail() {
      this.showLoading("正在获取电影信息");
      let resp = await this.$http.get(
        `/maoyanApi/ajax/detailmovie?movieId=${this.$route.params.id}`
      );
      resp.data.detailMovie.img = resp.data.detailMovie.img.replace("w.h","128.180");
      this.detailMovieList = resp.data.detailMovie;
      this.hideLoading();
    },
    hideVideo(){
      this.$refs.video.pause();
      this.videoState=0;
    }
  }
};
</script>
<style lang="scss" scoped>
.body {
  background: #f4f4f4;
}
.back {
  position: absolute;
  left: 0.2rem;
  font-size: 0.6rem;
}
.collect {
  position: absolute;
  font-size: 0.6rem;
  right: 0.2rem;
}
.share {
  position: absolute;
  font-size: 0.6rem;
  right: 1rem;
}
.content {
  display: flex;
  position: relative;
  box-sizing: border-box;
  padding: 0.1rem;
  z-index: 1;
  .left {
    width: 2rem;
    img {
      width: 100%;
    }
  }
  .center {
    margin: 0;
    padding: 0;
    list-style-type: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    margin-left: 0.2rem;
    flex: 1;
    font-size: 0.28rem;
    color: white;
    .nm {
      font-size: 0.44rem;
      font-weight: bold;
    }
    .sc {
      @extend .nm;
      color: orange;
    }
  }
  .bgImg {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    filter: blur(10px);
    z-index: -1;
  }
  .right {
    width: 1.4rem;
    display: flex;
    justify-content: center;
    align-items: center;
    > span {
      font-size: 1rem;
      color: white;
    }
  }
}
.By {
  padding: 0.1rem;
  margin: 0.8rem 0px 0;
  box-sizing: border-box;
  button {
    background: var(--pColor);
    border: none;
    outline: none;
    width: 100%;
    height: 0.6rem;
    border-radius: 0.1rem;
  }
}
.dra {
  font-size: 12px;
  text-indent: 2em;
  line-height: 2;
  background: white;
  border-radius: 0.1rem;
  padding: 0.1rem;
  box-sizing: border-box;
  max-height: 1.1rem;
  overflow: hidden;
  &.active{
      max-height: 100%;
  }
}
.slideToggle{
  display: flex;
  justify-content: center;
  align-items: center;
  background: white;
}
.movieVideo{
  position: fixed;
  top:0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.8);
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  >video{
    width: 100%;
    height: 40%;
  }
}
</style>